<template>
  <div class="main">
    <!-- <h2>Home</h2> -->
    <el-container class="main-content">
      <!-- <el-aside width="200px"><main-menu /></el-aside> -->
      <!-- :is-fold="isCollapse" 传递给子组件 控制菜单折叠 -->
      <el-aside :width="isCollapse ? '60px' : '200px'"
        ><main-menu :is-collapse="isCollapse"
      /></el-aside>

      <el-container>
        <!-- height 是属性 直接用 -->
        <!-- fold-change 这里必须是自组件中的自定义事件名称 foldChange -->
        <el-header height="60px"><main-header @fold-change="handleFoldChange" /></el-header>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
    <!-- <button @click="loginOut">退出登陆</button> -->
  </div>
</template>

<script setup lang="ts">
import { ref, watch } from 'vue'
import MainMenu from '@/components/nav-menu/main-menu.vue'
import MainHeader from '@/components/main-header/main-header.vue'
// import router from '@/router'
// import { localCache } from '@/utils/cache'
// import { getUserInfoRequest, getUserListRequest } from '@/service/login/login.ts'

// function loginOut() {
//   localCache.removeCache('token')
//   localCache.removeCache('id')
//   localCache.removeCache('name')
//   router.push('/login')
// }

// 处理main-header 子组件中折叠的变换
const isCollapse = ref(false)
function handleFoldChange(isFold: boolean) {
  isCollapse.value = isFold
}
</script>

<style lang="less" scoped>
.main {
  height: 100%;
}

.main-content {
  height: 100%;

  .el-aside {
    overflow-x: hidden;
    overflow-y: auto;
    line-height: 200px;
    text-align: left;
    cursor: pointer;
    background-color: #001529;
    scrollbar-width: none; /* firefox */
    -ms-overflow-style: none; /* IE 10+ */

    transition: width 0.4s ease; /* 宽度延时变化  */

    &::-webkit-scrollbar {
      display: none;
    }
  }

  .el-main {
    background-color: #f0f2f5;
  }
}
</style>
